/**
 * 
 */
package com.scaffold.springmvc.action;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.scaffold.BasicBizAction;

/**
 * @author wangjg
 *
 */
@Controller
public class JSAction extends BasicBizAction{

	private static final String[] jsArray = {"util2", "FormUtil", "validator", "common"};

	@RequestMapping("/jcx/{v}/full.js")
	public String js_full(ModelMap model, @PathVariable String v){
		return js_part(model, v, "1230");
	}
	
	@RequestMapping("/jcx/{v}/{part}/js.js")
	public String js_part(ModelMap model, @PathVariable String v, @PathVariable String part){
		char[] sa = part.toCharArray();
		for(int i=0;i<sa.length;i++){
			try{
				int index = Integer.parseInt(String.valueOf(sa[i]));
				if(index<jsArray.length){
					String js = jsArray[index];
					model.put(js, "Y");
				}
			}catch(Exception e){
				e.printStackTrace();
			}
		}
		return "/commons/js.jsp";
	}
	
}
